package com.shujia.scala

import scala.io.Source

object Demo35Implcit {
  def main(args: Array[String]): Unit = {
    //隐式转换类
    val path = "data/students.txt"
    //Source.fromFile(path).getLines().toList

    val students: List[String] = path.readLines()
    println(students)

    val scores: List[String] = "data/score.txt".readLines()
    println(scores)
  }

  //隐式转换类：可以将类的参数类型转换类本身的类型
  implicit class Read(path: String) {
    def readLines(): List[String] = {
      Source.fromFile(path).getLines().toList
    }
  }
}
